import sys

arg = "tm"
while sys.stdin:
  line = sys.stdin.readline()
  toks = line.strip().split()
  if not toks:
    break
  if toks[0] == "track":
    # first line
    print "%s->num_nodes = %d;" % (arg, int(toks[1]))
    print
  else:
    # track node spec
    id = int(toks[0])
    last_id = id
    name = toks[1]
    type = toks[2]
    if toks[3].startswith("0x"):
      id2 = int(toks[3], 16)
    else:
      id2 = int(toks[3])
    x = int(toks[4])
    y = int(toks[5])
    if type == "sensor":
      print "%s->sensor_nodes[%d * 2] = %d;" % (arg, id, id)
      print "%s->sensor_nodes[%d * 2 + 1] = %d;" % (arg, id, id)
      print "%s->nodes[%d].type = NODE_SENSOR;" % (arg, id)
      print "StringCopy(%s->nodes[%d].name, \"%s\");" % (arg, id, name)
      print "%s->nodes[%d].id = %d;" % (arg, id, id)
      print "%s->nodes[%d].id2 = %d;" % (arg, id, id2)
      # read first edge
      line = sys.stdin.readline()
      toks = line.strip().split()
      dest = int(toks[0])
      distance = int(toks[2])
      print "%s->nodes[%d].se.ahead.dest = %d;" % (arg, id, dest)
      print "%s->nodes[%d].se.ahead.distance = %d;" % (arg, id, distance)
      # read second edge
      line = sys.stdin.readline()
      toks = line.strip().split()
      dest = int(toks[0])
      distance = int(toks[2])
      print "%s->nodes[%d].se.behind.dest = %d;" % (arg, id, dest)
      print "%s->nodes[%d].se.behind.distance = %d;" % (arg, id, distance)
      print "%s->nodes[%d].se.trig_forward = 0;" % (arg, id)
      print "%s->nodes[%d].se.trig_back = 0;" % (arg, id)
      print "%s->nodes[%d].x = %d;" % (arg, id, x)
      print "%s->nodes[%d].y = %d;" % (arg, id, y)
      print
    elif type == "switch":
      set = toks[6]
      print "%s->nodes[%d].type = NODE_SWITCH;" % (arg, id)
      print "StringCopy(%s->nodes[%d].name, \"%s\");" % (arg, id, name)
      print "%s->nodes[%d].id = %d;" % (arg, id, id)
      print "%s->nodes[%d].id2 = %d;" % (arg, id, id2)
      # read ahead straight
      line = sys.stdin.readline()
      toks = line.strip().split()
      dest = int(toks[0])
      distance = int(toks[2])
      print "%s->nodes[%d].sw.ahead[1].dest = %d;" % (arg, id, dest)
      print "%s->nodes[%d].sw.ahead[1].distance = %d;" % (arg, id, distance)
      # read ahead curved
      line = sys.stdin.readline()
      toks = line.strip().split()
      dest = int(toks[0])
      distance = int(toks[2])
      print "%s->nodes[%d].sw.ahead[0].dest = %d;" % (arg, id, dest)
      print "%s->nodes[%d].sw.ahead[0].distance = %d;" % (arg, id, distance)
      # read behind
      line = sys.stdin.readline()
      toks = line.strip().split()
      dest = int(toks[0])
      distance = int(toks[2])
      print "%s->nodes[%d].sw.behind.dest = %d;" % (arg, id, dest)
      print "%s->nodes[%d].sw.behind.distance = %d;" % (arg, id, distance)
      print "%s->nodes[%d].x = %d;" % (arg, id, x)
      print "%s->nodes[%d].y = %d;" % (arg, id, y)
      if set == "curved":
        print "%s->nodes[%d].sw.set = SWITCH_CURVED;" % (arg, id)
      elif set == "straight":
        print "%s->nodes[%d].sw.set = SWITCH_STRAIGHT;" % (arg, id)
    elif type == "stop":
      print "%s->nodes[%d].type = NODE_STOP;" % (arg, id)
      print "StringCopy(%s->nodes[%d].name, \"%s\");" % (arg, id, name)
      print "%s->nodes[%d].id = %d;" % (arg, id, id)
      print "%s->nodes[%d].id2 = %d;" % (arg, id, id2)
      # read ahead
      line = sys.stdin.readline()
      toks = line.strip().split()
      dest = int(toks[0])
      distance = int(toks[2])
      print "%s->nodes[%d].st.ahead.dest = %d;" % (arg, id, dest)
      print "%s->nodes[%d].st.ahead.distance = %d;" % (arg, id, distance)
      print "%s->nodes[%d].x = %d;" % (arg, id, x)
      print "%s->nodes[%d].y = %d;" % (arg, id, y)
      print
